{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import shutil\n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "images_src_folder = 'D:/Data/mc_data/train/images/0/'\n",
    "masks_src_folder='D:/Data/mc_data/train/masks/0/'\n",
    "\n",
    "images_target_folder='D:/Data/mc_data/test/images/0/'\n",
    "masks_target_folder='D:/Data/mc_data/test/masks/0/'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9999\n",
      "19999\n",
      "29999\n",
      "39999\n",
      "49999\n",
      "59999\n"
     ]
    }
   ],
   "source": [
    "# 从train中随机抽出60317张图片和mask，当做test数据集\n",
    "count = 60317\n",
    "names =os.listdir(images_src_folder)\n",
    "sampled = random.sample(names, count)\n",
    "for idx,n in enumerate(sampled):\n",
    "    image_src_name = images_src_folder + n\n",
    "    mask_src_name = masks_src_folder + n\n",
    "    image_target_name = images_target_folder + n\n",
    "    mask_target_name = masks_target_folder + n\n",
    "    shutil.move(image_src_name, image_target_name)\n",
    "    shutil.move(mask_src_name, mask_target_name)\n",
    "    if (idx+1) % 10000 == 0:\n",
    "        print(idx)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
